﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.BOM;
using FriendStar.Domain.IRepository.BOM;
using FriendStar.Repository.BOM;

namespace FriendStar.Application.BOM
{
    /// <summary>
	/// 数据视图 V_XLK_21_MX_MatCardListAcco 对应的数据应用功能类。
	/// </summary>
	public class V_XLK_21_MX_MatCardListAccoApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_XLK_21_MX_MatCardListAccoRepository service = new V_XLK_21_MX_MatCardListAccoRepository();

        public List<V_XLK_21_MX_MatCardListAccoEntity> GetList(Pagination pagination, string status, string keyword)
        {
            var expression = ExtLinq.True<V_XLK_21_MX_MatCardListAccoEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            expression = expression.And(t => t.MaintainStatus == status);
            string extWhere = string.Empty;
            if (!string.IsNullOrEmpty(keyword))
            {
                if (!string.IsNullOrEmpty(extWhere))
                {
                    extWhere += " and ";
                }
                extWhere += string.Format("(FProductionNO like '%{0}%' or FProductionName like '%{0}%')", keyword);
            }
            return service.FindList(expression, pagination, extWhere);
        }

        public List<V_XLK_21_MX_MatCardListAccoEntity> GetList(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return new List<V_XLK_21_MX_MatCardListAccoEntity>();
            }

            var expression = ExtLinq.True<V_XLK_21_MX_MatCardListAccoEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            expression = expression.And(t => t.FProductionNO == id);
            return service.FindList(expression);
        }

        public V_XLK_21_MX_MatCardListAccoEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }

        public void UpdateForm(V_XLK_21_MX_MatCardListAccoEntity entity)
        {
            service.Update(entity);
        }
    }
}